package com.fresher.model;

import java.io.Serializable;

import javax.persistence.*;

import java.util.List;


/**
 * The persistent class for the users database table.
 * 
 */
@Entity
@Table(name="users")
//@NamedQuery(name="User.findAll", query="SELECT u FROM User u")
public class User implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private String username;

	private byte accountNonExpired;

	private byte accountNonLocked;

	private byte credentialsNonExpired;

	private byte enabled;

	private String password;
	
	

	public User(String username, String password) {
		super();
		this.username = username;
		this.password = password;
	}

	//bi-directional many-to-one association to Accountinfo
	@OneToMany(mappedBy="user",fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	private List<Accountinfo> accountinfos;

	//bi-directional many-to-one association to Log
	@OneToMany(mappedBy="user",fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	private List<Log> logs;

	//bi-directional many-to-one association to UserRole
	@OneToMany(mappedBy="user",fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	private List<UserRole> userRoles;

	public User() {
	}

	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public byte getAccountNonExpired() {
		return this.accountNonExpired;
	}

	public void setAccountNonExpired(byte accountNonExpired) {
		this.accountNonExpired = accountNonExpired;
	}

	public byte getAccountNonLocked() {
		return this.accountNonLocked;
	}

	public void setAccountNonLocked(byte accountNonLocked) {
		this.accountNonLocked = accountNonLocked;
	}

	public byte getCredentialsNonExpired() {
		return this.credentialsNonExpired;
	}

	public void setCredentialsNonExpired(byte credentialsNonExpired) {
		this.credentialsNonExpired = credentialsNonExpired;
	}

	public byte getEnabled() {
		return this.enabled;
	}

	public void setEnabled(byte enabled) {
		this.enabled = enabled;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public List<Accountinfo> getAccountinfos() {
		return this.accountinfos;
	}

	public void setAccountinfos(List<Accountinfo> accountinfos) {
		this.accountinfos = accountinfos;
	}

	public Accountinfo addAccountinfo(Accountinfo accountinfo) {
		getAccountinfos().add(accountinfo);
		accountinfo.setUser(this);

		return accountinfo;
	}

	public Accountinfo removeAccountinfo(Accountinfo accountinfo) {
		getAccountinfos().remove(accountinfo);
		accountinfo.setUser(null);

		return accountinfo;
	}

	public List<Log> getLogs() {
		return this.logs;
	}

	public void setLogs(List<Log> logs) {
		this.logs = logs;
	}

	public Log addLog(Log log) {
		getLogs().add(log);
		log.setUser(this);

		return log;
	}

	public Log removeLog(Log log) {
		getLogs().remove(log);
		log.setUser(null);

		return log;
	}

	public List<UserRole> getUserRoles() {
		return this.userRoles;
	}

	public void setUserRoles(List<UserRole> userRoles) {
		this.userRoles = userRoles;
	}

	public UserRole addUserRole(UserRole userRole) {
		getUserRoles().add(userRole);
		userRole.setUser(this);

		return userRole;
	}

	public UserRole removeUserRole(UserRole userRole) {
		getUserRoles().remove(userRole);
		userRole.setUser(null);

		return userRole;
	}

}